<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>补充语法2</title>
</head>
<body>
    <script>
        {
            //set
            let s=new Set([1,1,2,3]);
            console.log(s);
            s.add(4);
            console.log(s);
            s.delete(1);
            console.log(s);
            let res=s.has(1);
            console.log(res);
            s.forEach(v=>{
                console.log(v);
            })
            //console.log(s[0]);元素不可用[]调用
            s.clear();
            console.log(s);
            let s2=Array.from(new Set([1,1,1,2,2,3,3,3,3,4,5,6]));
            console.log(s2);
        }
        {
            //map
            let m=new Map();
            console.log(m);
            m.set(true,12);
            m.set(false,13);
            function fn() {
            }
            m.set(fn,14);
            let obj={name:"zs"};
            m.set(obj,15);
            console.log(m);
            console.log(m.get(obj));//返回键对应的值
            m.delete(fn);
            console.log(m);
            let res=m.has(fn);
            console.log(res);
            m.forEach(v=>{
                console.log(v);
            })
            //console.log(m[0]);元素不可用[]调用
        }
        {
            //Set,Map,Array共有方法
            let arr=[1,2,3];
            let res1=arr.entries();
            for (let i of res1) {
                console.log(i)
            }
            let s=new Set([1,1,2,3]);
            let res2=s.entries();
            for (let i of res2) {
                console.log(i)
            }
            let m=new Map();
            m.set(true,12);
            m.set(false,13);
            function fn() {}
            m.set(fn,14);
            let obj={name:"zs"};
            m.set(obj,15);
            let res3=m.entries();
            for (let i of res3) {
                console.log(i)
            }
        }
    </script>
</body>
</html>